<form class="layui-form layui-card" action="{:request()->url()}" data-auto="true" method="post" autocomplete="off">
    <div class="layui-card-body">
        <div class="layui-form-item">
            <label class="layui-form-label">轮播图名称</label>
            <div class="layui-input-block">
                <input name="name" required="required" value='{$vo.name|default=""}' placeholder="轮播图名称"
                       class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                {foreach ['1'=>'视频','2'=>'图片'] as $k=>$v}
                <input type="radio" data-bannertype="{$k}" name="type" value="{$k}" title="{$v}" lay-filter="bannertype">
                {/foreach}
            </div>
        </div>
        <div data-type="1">
            <div class="layui-form-item">
                <label class="layui-form-label">视频<span class="nowrap color-red">750*940</span></label>
                <div class="layui-input-block">
                    <video id="goods-video" width="375" height="200" controls
                           src="{$vo.video|default=''}"></video>
                    <input name="video" class="layui-input" placeholder="仅支持mp4格式视频"
                           value="{$vo.video|default=''}"
                           onchange="$('#goods-video').attr('src',this.value)">
                    <a class="layui-btn layui-btn-primary" data-file="one" data-field="video"
                       data-type="mp4"><i class="layui-icon font-s14 layui-icon-upload-drag"></i>上传视频</a>
                    <p class="layui-word-aux">选填,请上传mp4格式的视频，如格式不一致请前往<a href="http://www.pcfreetime.com/"
                                                                         target="_blank">格式工厂</a>转换格式</p>
                </div>
            </div>
        </div>
        <div data-type="2">
            <div class="layui-form-item">
                <label class="layui-form-label label-required">轮播图<span class="nowrap color-red">750*940</span></label>
                <div class="layui-input-block">
                    <input name="image" data-upload-image type="hidden" value="{$vo.image|default=''}">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">关联样片</label>
            <div class="layui-input-block">
                <input name="sample_id" value="{$vo.sample_id|default=''}" data-source="{:url('/backend/sample/selectpage')}" data-position="fixed" data-field="name" placeholder="请选择样片，可搜索名称" class="layui-input selectpage">
                <!-- <div class="selectN" data-source="{:url('/backend/enterprise/selectN')}"
                     data-input-name="enterprise_id"
                     data-selected="{$vo.enterprise_id|default=''},{$vo.enterprise_id|default=''}"
                     data-field="name">
                </div> -->
            </div>
        </div>
      <!--  <div class="layui-form-item">
            <label class="layui-form-label">轮播图链接</label>
            <div class="layui-input-block">
                <input name="url" value='{$vo.url|default=""}' placeholder="轮播图链接"
                       class="layui-input">
            </div>
        </div>
 -->
    </div>
    <div class="hr-line-dashed"></div>
    <div class="layui-form-item text-center">
        <!--{notempty name='vo.id'}-->
        <input type='hidden' value='{$vo.id}' name='id'>
        <!--{/notempty}-->
        <button class="layui-btn" type='submit'>保存数据</button>
        <button class="layui-btn layui-btn-danger" type='button' data-confirm="确定要取消编辑吗？" data-close>取消编辑</button>
    </div>

</form>


{block name="script"}
<script>
    require(['layui'],function () {
        layui.use(['form','laydate','layer'],function() {
            window.form = layui.form;
            require(['form'], function () {
                apply('{$vo.type|default="1"}');
                window.form.render();
                window.form.on('radio(bannertype)', function (data) {
                    apply(data.value);

                });

                function apply(value) {
                    console.log(value);
                    var $active = $("[data-bannertype='" + value + "']").trigger('click');
                    if ($active.size() < 1) $("[data-bannertype]:first").trigger('click');
                    $('[data-type="' + value + '"]').show().siblings('[data-type]').hide();
                }
            })

        })
    });
</script>
{/block}